#ifndef MAPMANAGER_HPP
# define MAPMANAGER_HPP

# include <QDomDocument>
# include <QString>
# include "Map.hpp"
# include "SpriteSheet.hpp"

class MapManager
{
public:
    MapManager();

    void    save(std::list<SpriteSheet*>& spriteSheets, Map& map, QString const& fileName);
    Map*    load(QString const& fileName, std::list<SpriteSheet*>& sheetsDictionary);

private:
    void    writeToFile(QDomDocument& document, const QString &fileName);
    void    addToDom(QDomDocument& document, QDomElement& element, QString const& name, QString const& value);
    void    addToDom(QDomDocument& document, QDomElement& element, QString const& name, int value);

    void    buildDomFromFile(QDomDocument& document, QString const& fileName);
    void    loadTiles(QDomElement& child, Map* newMap, std::list<SpriteSheet*>& sheetsDictionary);
    void    loadSheets(QDomElement& child, std::list<SpriteSheet*>& sheetsDictionary);
};

#endif // MAPMANAGER_HPP
